package 蓝桥._14届.子矩阵;

import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
    static int mod = 998244353;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int m = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int[][] t = new int[n][m];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                t[i][j] = scan.nextInt();
            }
        }
        int ans = 0;


        // 滑动窗口
        for(int i=0;i<n-a+1;i++){

            long min = Integer.MAX_VALUE, max = 0;

            for (int j = 0; j < m-b+1; j++) {
                for (int k = 0; k < a; k++) {
                    for (int l = 0; l < b; l++) {
                        min = Math.min(min, t[i+k][j+l]);
                        max = Math.max(max, t[i+k][j+l]);
                    }
                }
                ans = (int) (((min*max) % mod + ans)%mod);
            }
        }
        System.out.println(ans);



        scan.close();
    }
}